<?php

namespace App\Services\Account;

use Illuminate\Database\Eloquent\Relations\HasMany;

class AccountBalances extends AccountAbstract
{
    protected function account(): HasMany
    {
        return $this->user->balances();
    }

    /*---------- plus --------------------------------------------------------------------------------------------------*/

    public function plusGroupBalances($apples,$data = [])
	{
		$apples = big_decimal($apples);
		$this->record($apples, 'group_balances', '成团奖励', $data);
	}

	  public function plusRewardsToBalances($money,$data = [])
	{
		$money = big_decimal($money);
		$this->record($money, 'rewards_exchange_balances', '佣金结算到余额', $data);
	}
	
	public function plusRefusedWithdrawPrincipal($coins, $data = [])
	{
        $coins = big_decimal($coins);
		$this->record($coins, 'withdraw_refusal_principal', '提现驳回返还本金', $data);
	}

	public function plusRefusedWithdrawCharge($coins, $data = [])
	{
        $coins = big_decimal($coins);
		$this->record($coins, 'withdraw_refusal_charge', '提现驳回返还手续费', $data);
	}

	public function plusFailedWithdrawPrincipal($coins, $data = [])
	{
        $coins = big_decimal($coins);
		$this->record($coins, 'withdraw_failed_principal', '提现失败返还本金', $data);
	}

	public function plusFailedWithdrawCharge($coins, $data = [])
	{
        $coins = big_decimal($coins);
		$this->record($coins, 'withdraw_failed_charge', '提现失败返还手续费', $data);
	}

	public function plusSystemTransferBalances($coins, $data = [])
	{
        $coins = big_decimal($coins);
		$this->record($coins, 'system_transfer_balances', '系统转账', $data);
	}

	public function plusCompanyTransferBalances($coins, $data = [])
	{
        $coins = big_decimal($coins);
		$this->record($coins, 'company_transfer_balances', '工资发放', $data);
	}
	
	public function plusOrderRefund($coins, $data = [])
	{
        $coins = big_decimal($coins);
		$this->record($coins, 'order_refund', '商品订单退款', $data);
	}


	public function plusOrderRewards($rewards,$name, $data = [])
	{
        $rewards = big_decimal($rewards);
		$this->record($rewards, 'order_ptjl', "平台奖励", $data);
	}



	/*---------- minus -------------------------------------------------------------------------------------------------*/
	public function minusWithdrawPrincipal($money, $data = [])
	{
		$money = big_decimal($money)->multipliedBy(-1);
		$this->record($money, 'withdraw_principal', '提现', $data);
	}

	public function minusWithdrawCharge($money, $data = [])
	{
		$money = big_decimal($money)->multipliedBy(-1);
		$this->record($money, 'withdraw_charge', '提现手续费', $data);
	}
	public function minusBalancesExchangeCoupons($money, $data = [])
	{
		$money = big_decimal($money)->multipliedBy(-1);
		$this->record($money, 'balances_exchange_Coupons', '积分兑换优惠卷', $data);
	}
	
	public function minusVipPaid($money, $data = [])
	{
		$money = big_decimal($money)->multipliedBy(-1);
		$this->record($money, 'pay_vip_balance', '余额购买vip', $data);
	}


	public function minusSystemRecallBalances($apples, $data = [])
	{
		$apples = big_decimal($apples)->multipliedBy(-1);
		$this->record($apples, 'system_recall', '系统回收', $data);
	}


	
}
